import { Inject, Injectable } from '@angular/core';

class CatchManager{
    cacheMap = new Map();
    
    getValue(key) { 
        return this.cacheMap.get(key); 
    } 
    
    addOrReplaceCache(key,value) { 
        this.cacheMap.set(key, value); 
    } 
    
    evictCache(key) {// 根据 key 来删除缓存中的一条记录
        if(key) {
            this.cacheMap.delete(key); 
        } else {
            this.clear();
        }
    } 
    
    clear() {// 清空缓存中的所有记录
        this.cacheMap.clear();
    }
}

export const catchManager = new CatchManager();
